import sys,math,os
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
class ListViewDemo(QWidget):
    def __init__(self,parent=None):
        super(ListViewDemo,self).__init__(parent)
        self.setWindowTitle("QListView例子")
        self.resize(300,700)
        layout=QVBoxLayout()
        listView=QListView()
        slm=QStringListModel()
        self.qList=["Item1","Item2","Item3","Item4"]
        slm.setStringList(self.qList)

        listView.setModel(slm)

        listView.clicked.connect(self.clicked)
        listView.doubleClicked.connect(self.doubleClicked)
        layout.addWidget(listView)
        self.setLayout(layout)
    def clicked(self,qmodelIndex):
        QMessageBox.information(self,"ListView","你选择了:"+self.qList[qmodelIndex.row()])

    def doubleClicked(self,qmodelIndex):
        QMessageBox.information(self,"ListView","双击你选择了:"+self.qList[qmodelIndex.row()])

if __name__ == '__main__':
    app=QApplication(sys.argv)
    table=ListViewDemo()
    table.show()
    sys.exit(app.exec_())